Due Feb 24, 2:59 AM EST
Consider the following python code
12345for _ in range(7):print("Hello world!")for _ in range(6):print("Hello world!")Enter to Rename, ⇧Enter to Preview
If we run this code, how many times the phrase 'Hello world!' will be printed? Try to answer without actually running the code.
The first 'for' will run seven times and the second 'for' will run six times. In each 'for' the phrase `Hello world!' is printed once, so by rule of sum in total the word will be printed 7+6=13 times
Consider the following python code
1234567for _ in range(8):print("Hi!")for _ in range(4):print("Hi!")for _ in range(7):print("Hi!")Enter to Rename, ⇧Enter to Preview
If we run this code, how many times the word 'Hi!' will be printed? Try to answer without actually running the code.
The first 'for' will run 8 times, the second 'for' will run 4 times and the third 'for' will run 7 times. In each 'for' the word `Hi!' is printed once, so if we apply the rule of sum twice we get that in total the word will be printed 8+4+7=19 times